﻿using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IotClientService.Models.Lg;
/// <summary>
/// 接收信息
/// </summary>
public class LgMsgInfo
{
    /// <summary>
    /// 方向  0 FMS->设备  1 设备->FMS
    /// </summary>
    public int Direction { get; set; }
    /// <summary>
    /// 对象id lineid+equiptypeid+unitid
    /// </summary>
    public string ObjID { get; set; }
    /// <summary>
    /// 0 无 1有
    /// </summary>
    public int HasMsg { get; set; }
    /// <summary>
    /// 命令
    /// </summary>
    public string Command { get; set; }
    /// <summary>
    /// 序列号
    /// </summary>
    public string SeqNo { get; set; }
    /// <summary>
    /// 充放电单独，其它9固定
    /// </summary>
    public int BoxId { get; set; } = 9;
    /// <summary>
    /// 所有信息
    /// </summary>
    public string Message { get; set; }
    /// <summary>
    /// 消息体
    /// </summary>
    public string Body { get; set; }

    
    /// <summary>
    /// 是否应该发送
    /// </summary>
    public bool IsSend { get; set; }

    

    /// <summary>
    /// 计算总数
    /// </summary>
    /// <param name="parmStrMsg"></param>
    /// <param name="parmCSInclude"></param>
    /// <returns></returns>
    public new string MakeCheckSum(string parmStrMsg)
    {
        string result = string.Empty;

        
        long sum = 0L;
        int length = parmStrMsg.Length;
        for (int i = 0; i < length; i++)
        {
            sum += parmStrMsg[i];
        }
        string sumStr = sum.ToString();
       
        result = sumStr.Substring(sumStr.Length - 2);
      
        return result;

    }





}
